// hyb_yl/mysubpages/pages/patientman/patientman.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tabitem: ['签约患者', '普通患者', '年卡患者', '手术患者'],
    docindex: 0,
    qyPatient: [{}, {}, {}],
    ptPatient: [{}, {}, {}, {}],
    nkPatient: [{}, {}, {}, {}, {}],
    list: [],
    page: 0,
    pagesize: 10,

  },
  doctab: function (e) {

    const index = e.currentTarget.dataset.dex;
    this.setData({
      docindex: index,
      list: [],
      page: 0,
    })
    wx.showLoading({
      title: 'login..',
    })
    this.getList(index)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var zid = options.zid;
    var docindex = options.state - 1;
    that.setData({
      zid: zid,
      docindex: docindex
    })
    that.getList(docindex);

  },
  getList: function (index) {
    var that = this;
    app.util.request({
      'url': 'entry/wxapp/zhuanjia.getqylistser',
      data: {
        goods_id: that.data.zid,
        cerated_type: 7,
        index: index,
        page: that.data.page,
        pagesize: that.data.pagesize
      },
      success: function (res) {
        console.log(res)
        var page = that.data.page + 1;
        that.setData({
          list: that.data.list.concat(res.data),
          page: page
        })
        wx.hideLoading()
      }
    })
  },
  // getOrder: function (type) {
  //   var that = this;
  //   app.util.request({
  //     'url': "entry/wxapp/team.team_order",
  //     data: {
  //       id: that.data.id,
  //       page: that.data.page,
  //       pagesize: that.data.pagesize,
  //       type: type
  //     },
  //     success: function (res) {
  //       var page = that.data.page + 1;
  //       that.setData({
  //         page: page,
  //         list: that.data.list.concat(res.data)
  //       })
  //     }
  //   })
  // },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    this.getList(this.data.docindex)
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  see(e) {
    var that = this
    var change = e.currentTarget.dataset.change
    var openid = e.currentTarget.dataset.openid
    var titlme = e.currentTarget.dataset.names
    wx.navigateTo({
      url: '/hyb_yl/zhuanjiasubpages/pages/danganList/danganList?openid=' + openid + '&doc=1' + '&type=1' + '&titlme=' + titlme,
    })
    // if (change == '1') {
    //   wx.navigateTo({
    //     url: '/hyb_yl/zhuanjiasubpages/pages/danganList/danganList?openid=' + openid + '&doc=1' + '&type=1' + '&titlme=' + titlme,
    //   })
    // } else {
    //   wx.showToast({
    //     title: '患者未授权',
    //     icon: 'none'
    //   })
    // }
  },
  tongguo(e) {
    var that = this
    var id = e.currentTarget.dataset.id
    var zid = that.data.zid
    app.util.request({
      'url': 'entry/wxapp/zhuanjia.updateqianyue',
      data: {
        id: id
      },
      success: function (res) {
        console.log(res)
        app.util.request({
          'url': 'entry/wxapp/zhuanjia.getqylistser',
          data: {
            goods_id: zid,
            cerated_type: 7
          },
          success: function (res) {
            console.log(res)
            that.setData({
              list: res.data
            })
          }
        })
      }
    })
  },
  jujue(e) {
    var that = this
    var id = e.currentTarget.dataset.id
    var zid = that.data.zid
    app.util.request({
      'url': 'entry/wxapp/zhuanjia.updatejujueqianyue',
      data: {
        id: id
      },
      success: function (res) {
        console.log(res)
        app.util.request({
          'url': 'entry/wxapp/zhuanjia.getqylistser',
          data: {
            goods_id: zid,
            cerated_type: 7
          },
          success: function (res) {
            console.log(res)
            that.setData({
              list: res.data
            })
          }
        })
      }
    })
  },
  jiechu(e) {
    var that = this
    var id = e.currentTarget.dataset.id
    var zid = that.data.zid
    app.util.request({
      'url': 'entry/wxapp/zhuanjia.updatejiechuqianyue',
      data: {
        id: id
      },
      success: function (res) {
        console.log(res)
        app.util.request({
          'url': 'entry/wxapp/zhuanjia.getqylistser',
          data: {
            goods_id: zid,
            cerated_type: 7
          },
          success: function (res) {
            console.log(res)
            that.setData({
              list: res.data
            })
          }
        })
      }
    })
  }
})